
package std.collection.concurrent
import std.sync.*
import std.time.*

import std.collection.MapEntryView
import std.collection.ArrayList

@!APILevel[
    since: "22"
]
public class ArrayBlockingQueue<E> {
    @!APILevel[
        since: "22"
    ]
    public let capacity: Int64
    
    /**
    * @throws IllegalMemoryException
    * @throws IllegalArgumentException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public init(capacity: Int64)
    
    /**
    * @throws IndexOutOfBoundsException
    * @throws IllegalSynchronizationStateException
    * @throws IllegalMemoryException
    * @throws IllegalArgumentException
    */
    @Deprecated[message: "Use the other version of `init` instead."]
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public init(capacity: Int64, elements: Collection<E>)
    
    @!APILevel[
        since: "22"
    ]
    public prop size: Int64
    
    /**
    * @throws IndexOutOfBoundsException
    * @throws ArithmeticException
    * @throws IllegalArgumentException
    * @throws IllegalSynchronizationStateException
    */
    @Deprecated[message: "Use member function `public func add(element: E): Unit` instead."]
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func enqueue(element: E): Unit
    
    /**
    * @throws IndexOutOfBoundsException
    * @throws ArithmeticException
    * @throws IllegalArgumentException
    * @throws IllegalSynchronizationStateException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func add(element: E): Unit
    
    /**
    * @throws IndexOutOfBoundsException
    * @throws IllegalSynchronizationStateException
    * @throws IllegalArgumentException
    * @throws ArithmeticException
    */
    @Deprecated[message: "Use member function `public func add(element: E, timeout: Duration): Bool` instead."]
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func enqueue(element: E, timeout: Duration): Bool
    
    /**
    * @throws IndexOutOfBoundsException
    * @throws IllegalSynchronizationStateException
    * @throws IllegalArgumentException
    * @throws ArithmeticException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func add(element: E, timeout: Duration): Bool
    
    /**
    * @throws IndexOutOfBoundsException
    * @throws ArithmeticException
    * @throws IllegalArgumentException
    * @throws IllegalSynchronizationStateException
    * @throws Exception
    */
    @Deprecated[message: "Use member function `public func remove(): E` instead."]
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func dequeue(): E
    
    /**
    * @throws IndexOutOfBoundsException
    * @throws ArithmeticException
    * @throws IllegalArgumentException
    * @throws IllegalSynchronizationStateException
    * @throws Exception
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func remove(): E
    
    /**
    * @throws IndexOutOfBoundsException
    * @throws IllegalSynchronizationStateException
    * @throws IllegalArgumentException
    * @throws ArithmeticException
    */
    @Deprecated[message: "Use member function `public func remove(timeout: Duration): Option<E>` instead."]
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func dequeue(timeout: Duration): Option<E>
    
    /**
    * @throws IndexOutOfBoundsException
    * @throws IllegalSynchronizationStateException
    * @throws IllegalArgumentException
    * @throws ArithmeticException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func remove(timeout: Duration): Option<E>
    
    /**
    * @throws IndexOutOfBoundsException
    */
    @Deprecated[message: "Use member function `public func peek(): Option<E>` instead."]
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func head(): Option<E>
    
    /**
    * @throws IndexOutOfBoundsException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func peek(): Option<E>
    
    /**
    * @throws IndexOutOfBoundsException
    * @throws IllegalSynchronizationStateException
    */
    @Deprecated[message: "Use member function `public func tryAdd(element: E): Bool` instead."]
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func tryEnqueue(element: E): Bool
    
    /**
    * @throws IndexOutOfBoundsException
    * @throws IllegalSynchronizationStateException
    */
    @OverflowWrapping
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func tryAdd(element: E): Bool
    
    /**
    * @throws IndexOutOfBoundsException
    * @throws IllegalSynchronizationStateException
    */
    @Deprecated[message: "Use member function `public func tryRemove(): Option<E>` instead."]
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func tryDequeue(): Option<E>
    
    /**
    * @throws IndexOutOfBoundsException
    * @throws IllegalSynchronizationStateException
    */
    @OverflowWrapping
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func tryRemove(): Option<E>
}

@Deprecated[message: "Use LinkedBlockingQueue instead."]
@!APILevel[
    since: "22"
]
public type BlockingQueue<E> = LinkedBlockingQueue<E>

@!APILevel[
    since: "22"
]
public class LinkedBlockingQueue<E> {
    @!APILevel[
        since: "22"
    ]
    public let capacity: Int64
    
    /**
    * @throws IllegalArgumentException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public init(capacity: Int64)
    
    /**
    * @throws IllegalArgumentException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public init()
    
    /**
    * @throws IndexOutOfBoundsException
    * @throws IllegalSynchronizationStateException
    * @throws IllegalArgumentException
    */
    @Deprecated[message: "Use the other version of `init` instead."]
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public init(capacity: Int64, elements: Array<E>)
    
    /**
    * @throws IndexOutOfBoundsException
    * @throws IllegalSynchronizationStateException
    * @throws IllegalArgumentException
    */
    @Deprecated[message: "Use the other version of `init` instead."]
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public init(capacity: Int64, elements: Collection<E>)
    
    @!APILevel[
        since: "22"
    ]
    public prop size: Int64
    
    /**
    * @throws IndexOutOfBoundsException
    * @throws IllegalSynchronizationStateException
    * @throws ArithmeticException
    * @throws IllegalArgumentException
    */
    @Deprecated[message: "Use member function `public func add(element: E): Unit` instead."]
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func enqueue(element: E): Unit
    
    /**
    * @throws IndexOutOfBoundsException
    * @throws IllegalSynchronizationStateException
    * @throws ArithmeticException
    * @throws IllegalArgumentException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func add(element: E): Unit
    
    /**
    * @throws IndexOutOfBoundsException
    * @throws IllegalSynchronizationStateException
    * @throws IllegalArgumentException
    * @throws ArithmeticException
    */
    @Deprecated[message: "Use member function `public func add(element: E, timeout: Duration): Bool` instead."]
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func enqueue(element: E, timeout: Duration): Bool
    
    /**
    * @throws IndexOutOfBoundsException
    * @throws IllegalSynchronizationStateException
    * @throws IllegalArgumentException
    * @throws ArithmeticException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func add(element: E, timeout: Duration): Bool
    
    /**
    * @throws IndexOutOfBoundsException
    * @throws ArithmeticException
    * @throws IllegalArgumentException
    * @throws IllegalSynchronizationStateException
    * @throws Exception
    */
    @Deprecated[message: "Use member function `public func remove(): E` instead."]
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func dequeue(): E
    
    /**
    * @throws IndexOutOfBoundsException
    * @throws ArithmeticException
    * @throws IllegalArgumentException
    * @throws IllegalSynchronizationStateException
    * @throws Exception
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func remove(): E
    
    /**
    * @throws IndexOutOfBoundsException
    * @throws IllegalSynchronizationStateException
    * @throws IllegalArgumentException
    * @throws ArithmeticException
    */
    @Deprecated[message: "Use member function `public func remove(timeout: Duration): Option<E>` instead."]
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func dequeue(timeout: Duration): Option<E>
    
    /**
    * @throws IndexOutOfBoundsException
    * @throws IllegalSynchronizationStateException
    * @throws IllegalArgumentException
    * @throws ArithmeticException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func remove(timeout: Duration): Option<E>
    
    /**
    * @throws IndexOutOfBoundsException
    */
    @Deprecated[message: "Use member function `public func peek(): Option<E>` instead."]
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func head(): Option<E>
    
    /**
    * @throws IndexOutOfBoundsException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func peek(): Option<E>
    
    /**
    * @throws IndexOutOfBoundsException
    * @throws IllegalSynchronizationStateException
    */
    @Deprecated[message: "Use member function `public func tryAdd(element: E): Bool` instead."]
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func tryEnqueue(element: E): Bool
    
    /**
    * @throws IndexOutOfBoundsException
    * @throws IllegalSynchronizationStateException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func tryAdd(element: E): Bool
    
    /**
    * @throws IndexOutOfBoundsException
    * @throws IllegalSynchronizationStateException
    */
    @Deprecated[message: "Use member function `public func tryRemove(): Option<E>` instead."]
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func tryDequeue(): Option<E>
    
    /**
    * @throws IndexOutOfBoundsException
    * @throws IllegalSynchronizationStateException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func tryRemove(): Option<E>
}


@!APILevel[
    since: "22"
]
public class ConcurrentHashMap<K, V> <: ConcurrentMap<K, V> & Collection<(K, V)> where K <: Hashable & Equatable<K> {
    /**
    * @throws IllegalSynchronizationStateException
    * @throws IndexOutOfBoundsException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public init(concurrencyLevel!: Int64 = DEFAULT_CONCUR_LEVEL)
    
    /**
    * @throws IllegalSynchronizationStateException
    * @throws IndexOutOfBoundsException
    * @throws IllegalArgumentException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public init(capacity: Int64, concurrencyLevel!: Int64 = DEFAULT_CONCUR_LEVEL)
    
    /**
    * @throws IllegalSynchronizationStateException
    * @throws IllegalArgumentException
    * @throws IndexOutOfBoundsException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public init(elements: Collection<(K, V)>, concurrencyLevel!: Int64 = DEFAULT_CONCUR_LEVEL)
    
    /**
    * @throws IllegalSynchronizationStateException
    * @throws IndexOutOfBoundsException
    * @throws IllegalArgumentException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public init(size: Int64, initElement: (Int64) -> (K, V), concurrencyLevel!: Int64 = DEFAULT_CONCUR_LEVEL)
    
    /**
    * @throws IndexOutOfBoundsException
    */
    @Frozen
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func get(key: K): ?V
    
    /**
    * @throws IndexOutOfBoundsException
    */
    @Frozen
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func contains(key: K): Bool
    
    /**
    * @throws IllegalSynchronizationStateException
    * @throws IllegalArgumentException
    * @throws IndexOutOfBoundsException
    */
    @Deprecated[message: "Use member function `public func add(key: K, value: V): ?V` instead."]
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func put(key: K, value: V): ?V
    
    /**
    * @throws IllegalSynchronizationStateException
    * @throws IllegalArgumentException
    * @throws IndexOutOfBoundsException
    */
    @Frozen
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func add(key: K, value: V): ?V
    
    /**
    * @throws IllegalArgumentException
    * @throws IndexOutOfBoundsException
    * @throws IllegalSynchronizationStateException
    */
    @Deprecated[message: "Use member function `public func addIfAbsent(key: K, value: V): ?V` instead."]
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func putIfAbsent(key: K, value: V): ?V
    
    /**
    * @throws IllegalArgumentException
    * @throws IndexOutOfBoundsException
    * @throws IllegalSynchronizationStateException
    */
    @Frozen
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func addIfAbsent(key: K, value: V): ?V
    
    /**
    * @throws IllegalArgumentException
    * @throws IllegalSynchronizationStateException
    * @throws IndexOutOfBoundsException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func remove(key: K): ?V
    
    /**
    * @throws IllegalArgumentException
    * @throws IllegalSynchronizationStateException
    * @throws IndexOutOfBoundsException
    */
    @Deprecated[message: "Use member function `public func entryView(K, (MapEntryView<K, V>) -> Unit)` instead."]
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func remove(key: K, predicate: (V) -> Bool): ?V
    
    /**
    * @throws IllegalArgumentException
    * @throws IllegalSynchronizationStateException
    * @throws IndexOutOfBoundsException
    */
    @Frozen
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func replace(key: K, value: V): ?V
    
    /**
    * @throws IllegalArgumentException
    * @throws IllegalSynchronizationStateException
    * @throws IndexOutOfBoundsException
    */
    @Deprecated[message: "Use member function `public func entryView(key: K, fn: (MapEntryView<K, V>)->Unit): ?V` instead."]
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func replace(key: K, eval: (V) -> V): ?V
    
    /**
    * @throws IllegalArgumentException
    * @throws IllegalSynchronizationStateException
    * @throws IndexOutOfBoundsException
    */
    @Deprecated[message: "Use member function `public func entryView(key: K, fn: (MapEntryView<K, V>)->Unit): ?V` instead."]
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func replace(key: K, predicate: (V) -> Bool, eval: (V) -> V): ?V
    
    /**
    * @throws IllegalSynchronizationStateException
    * @throws IllegalArgumentException
    * @throws IndexOutOfBoundsException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func entryView(key: K, fn: (MapEntryView<K, V>) -> Unit): ?V
    
    /**
    * @throws IndexOutOfBoundsException
    * @throws NoneValueException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public operator func [](key: K): V
    
    /**
    * @throws IllegalSynchronizationStateException
    * @throws IllegalArgumentException
    * @throws IndexOutOfBoundsException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public operator func [](key: K, value!: V): Unit
    
    /**
    * @throws IndexOutOfBoundsException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public prop size: Int64
    
    /**
    * @throws IndexOutOfBoundsException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func isEmpty(): Bool
    
    /**
    * @throws IndexOutOfBoundsException
    */
    @Frozen
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func iterator(): ConcurrentHashMapIterator<K, V>
}

@!APILevel[
    since: "22"
]
public class ConcurrentHashMapIterator<K, V> <: Iterator<(K, V)> where K <: Hashable & Equatable<K> {
    /**
    * @throws IndexOutOfBoundsException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public init(cmap: ConcurrentHashMap<K, V>)
    
    /**
    * @throws IndexOutOfBoundsException
    */
    @Frozen
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func next(): Option<(K, V)>
}

@!APILevel[
    since: "22"
]
public interface ConcurrentMap<K, V> {
    @!APILevel[
        since: "22"
    ]
    func get(key: K): ?V
    
    @!APILevel[
        since: "22"
    ]
    func contains(key: K): Bool
    
    @Deprecated[message: "Use member function `func add(key: K, value: V): ?V` instead."]
    @!APILevel[
        since: "22"
    ]
    func put(key: K, value: V): ?V
    
    @!APILevel[
        since: "22"
    ]
    func add(key: K, value: V): ?V
    
    @Deprecated[message: "Use member function `func addIfAbsent(key: K, value: V): ?V` instead."]
    @!APILevel[
        since: "22"
    ]
    func putIfAbsent(key: K, value: V): ?V
    
    @!APILevel[
        since: "22"
    ]
    func addIfAbsent(key: K, value: V): ?V
    
    @!APILevel[
        since: "22"
    ]
    func remove(key: K): ?V
    
    @Deprecated[message: "Use member function `func entryView(key: K, fn: (MapEntryView<K, V>)->Unit): ?V` instead."]
    @!APILevel[
        since: "22"
    ]
    func remove(key: K, predicate: (V) -> Bool): ?V
    
    @!APILevel[
        since: "22"
    ]
    func replace(key: K, value: V): ?V
    
    @Deprecated[message: "Use member function `func entryView(key: K, fn: (MapEntryView<K, V>)->Unit): ?V` instead."]
    @!APILevel[
        since: "22"
    ]
    func replace(key: K, eval: (V) -> V): ?V
    
    @Deprecated[message: "Use member function `func entryView(key: K, fn: (MapEntryView<K, V>)->Unit): ?V` instead."]
    @!APILevel[
        since: "22"
    ]
    func replace(key: K, predicate: (V) -> Bool, eval: (V) -> V): ?V
    
    @!APILevel[
        since: "22"
    ]
    func entryView(key: K, fn: (MapEntryView<K, V>) -> Unit): ?V
    
    @!APILevel[
        since: "22"
    ]
    operator func [](key: K): V
    
    @!APILevel[
        since: "22"
    ]
    operator func [](key: K, value!: V): Unit
}

@Deprecated[message: "Use ConcurrentLinkedQueue instead."]
@!APILevel[
    since: "22"
]
public type NonBlockingQueue<E> = ConcurrentLinkedQueue<E>

@!APILevel[
    since: "22"
]
public class ConcurrentLinkedQueue<E> <: Collection<E> {
    @!APILevel[
        since: "22"
    ]
    public init()
    
    /**
    * @throws IndexOutOfBoundsException
    */
    @Deprecated[message: "Use the other version of `init` instead."]
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public init(elements: Collection<E>)
    
    @!APILevel[
        since: "22"
    ]
    public prop size: Int64
    
    /**
    * @throws IndexOutOfBoundsException
    */
    @Deprecated[message: "Use member function `func addIfAbsent(key: K, value: V): ?V` instead."]
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func enqueue(element: E): Bool
    
    /**
    * @throws IndexOutOfBoundsException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func add(element: E): Bool
    
    /**
    * @throws IndexOutOfBoundsException
    */
    @Deprecated[message: "Use member function `public func remove(): Option<E>` instead."]
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func dequeue(): Option<E>
    
    /**
    * @throws IndexOutOfBoundsException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func remove(): Option<E>
    
    /**
    * @throws IndexOutOfBoundsException
    */
    @Deprecated[message: "Use member function `public func peek(): Option<E>` instead."]
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func head(): Option<E>
    
    /**
    * @throws IndexOutOfBoundsException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func peek(): Option<E>
    
    /**
    * @throws IndexOutOfBoundsException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func isEmpty(): Bool
    
    /**
    * @throws IndexOutOfBoundsException
    * @throws IllegalArgumentException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func toArray(): Array<E>
    
    @Frozen
    @!APILevel[
        since: "22"
    ]
    public func iterator(): Iterator<E>
}

